<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1">
	<meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
	<meta name="author" content="Coderthemes">
	
	<!-- jQuery  -->
	<script src="/js/jquery3/jquery.min.js"></script>
	
	<!-- layui  -->
	<link rel="stylesheet" href="/js/layuiadmin-1.2.1/layui2.7.6/css/layui.css" media="all" />
	<script type="text/javascript" src="/js/layuiadmin-1.2.1/layui2.7.6/layui.js"></script>
	<script th:src="@{/dhecp/js/dh-ui.js?v=36}"></script>
	
</head>

<body>
	<form class="layui-form" id="id_form" method="post" action="">
		 <div class="layui-form-item">
		   <label class="layui-form-label"><i style="color:red">*&nbsp;&nbsp;</i>拆箱选项</label>
		   <div class="layui-input-block devanningList">
			   <input type="radio" name="devanning" value="0" title="拆箱">
			   <input type="radio" name="devanning" value="1" title="复建" >
		   </div>
		</div>
		<div class="layui-form-item">
		   <label class="layui-form-label"><i style="color:red">*&nbsp;&nbsp;</i>拆箱备注</label>
		   <div class="layui-input-block">
			   <textarea name="remark" maxlength="200" placeholder="请输入备注内容" class="layui-textarea remark"></textarea>
		   </div>
		</div>`
		<div class="layui-form-item">
			<div class="layui-layer-btn layui-layer-btn-" >
				<a class="layui-layer-btn0" lay-submit lay-filter="formDemo">确认</a>
				<a class="layui-layer-btn1 " id="closeBtn">取消</a>
			</div>
		</div>
	</form>
	<script>
	$(function () {
		layui.use(['form','layer'], function(){
			var form = layui.form;
			var layer = layui.layer;


			// 表单提交，共用同一个
			form.on('submit(formDemo)', function(data){
				//拆箱
				if (data.field.devanning == undefined){
					return layer.msg("请选择拆箱选项!")
				}
				if (data.field.remark == undefined || data.field.remark == null || data.field.remark == ''){
					return layer.msg("请填写拆箱备注!")
				}
				showloadings(true);
				$.post('[(${ali1688EcpApiUrl})]'+'/api/fbaInbound/devanningWc',{remark:data.field.remark,devanning:data.field.devanning,"code":'[(${code})]'},function(result){
					layer.msg(result.msg);
					if (result.code == 0) {
						setTimeout(function(){
							parent.layer.closeAll();
							sessionStorage.setItem('[(${moduleTable})]'+'checkdata','')
							parent.table.reload('dhtable', {page: {curr: 1}});
						}, 2000);
					}else {
						showloadings(false);
					}
				});
			});


			//取消 关闭弹框
			var obj = document.getElementById('closeBtn');
			obj.addEventListener('click', function cancel(){
				parent.layer.closeAll();
			});
		});
	});

	//加载中
	function showloadings(t) {
		if (t) {//如果是true则显示loading
			layer.load(2, {
				shade: [0.1, '#000'] //0.1透明度的白色背景
			});
		} else {//如果是false则关闭loading
			layer.closeAll('loading');
		}
	}

	</script>
</body>
</html>